home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 2
/
Gold Medal Software Volume 2 (Gold Medal) (1994).iso
/
utils
/
bt108.arj
/
BT.ASM
next >
Wrap
Assembly Source File
|
1994-01-25
|
10KB
|
399 lines
page ,132
title BootThru - v1.06
; For Borland:
; tasm bt
; tlink -t bt
;
;------------------------------------------------------------------------
;
; BootThru - Copyright (c) Bill Gibson - 1987
; Lathrup Village, Mi 48076
;
; Ver. 1.00 - Initial version (not rlsd) - 01/11/87
; 1.01 - revised code structure " - 01/25/87
; 1.02 - revised Modify Proc " - 02/01/87
; 1.03 - enhanced error message output " - 02/06/87
; 1.04 - revised Print Proc released - 02/07/87
; 1.05 - fix incompatibility plbm - 02/09/87
; 1.06 - fix problem with DOS 3.2 - 05/31/87
; DOS 3.2 believes the boot sector's information about
; the disk in the drive. v1.05 only worked with 360K disks.
; v1.06 now reads the old boot sector and transfers the
; information into the new boot sector.
; 1.07 - Took out waits
; Fixed up boot header to be like DOS 4.0 & 5.0
; 1.08 - Minor changes
;
;
; For Public Domain Use. Not for Sale or Hire.
; Last modified by:
; Ray Van Tassle
; 1020 Fox Run Lane
; Algonquin, Il 60102
; (708) 658-4941
;
;------------------------------------------------------------------------
COMMENT *
Routine to modify diskette boot record, using drive A: or B:,
thus circumventing DOS' non-system disk display error.
Usage:
BT A: -> transfer new boot record to drive A:
BT B: -> transfer new boot record to drive B:
BT -> starts program, default is drive A:
*
;------------------------------------------------------------------------
code SEGMENT BYTE PUBLIC 'code'
ASSUME CS:code,DS:code,SS:code
ORG 5Ch ;drive id
param1 LABEL BYTE
ORG 5Dh ;elim spurrious characters
param2 LABEL BYTE
ORG 100h
BootThru PROC FAR
CALL Chk_Ver ;dos 2.0 or greater
CALL Scan
CALL Dwrite
JMP SHORT exit
error:
CALL Print ;print error messages
MOV AL,1 ;set errorlevel to 1
exit:
MOV AH,4Ch
INT 21h
;------------------------------------------------------------------------
; Work Area - constants,equates,messages
;------------------------------------------------------------------------
drive DB 0
blank EQU 020h ;ascii space code
cr EQU 0Dh ;carriage return
lf EQU 0Ah ;line feed
ch_esc EQU 01Bh ;escape char
stopper EQU 255 ;end of display line indicator
logo DB cr,lf,'BootThru - The Diskette Modifier--boot thru floppy to the hard disk'
DB cr,lf,'Version 1.08 - Bill Gibson & Ray Van Tassle',cr,lf,stopper
usage DB cr,lf,'Usage: BT [drive A: or B:]',cr,lf
db ' Modifies floppy boot sector to boot from drive C:',stopper
sorry DB cr,lf,'Wrong PC DOS Version',cr,lf,stopper
msg1 DB cr,lf,'Insert diskette in drive '
drive_letter DB ?
db stopper
DB ' and press ENTER when ready ...',stopper
msg3 DB cr,lf,'Press ENTER to modify another disk',cr,lf
DB 'or ESCape to quit...',stopper
msg4 DB cr,lf,cr,lf,'Transferring New Boot Sector',cr,lf,stopper
msg5 DB cr,lf,'Transfer Completed',cr,lf,stopper
msg80h DB cr,lf,cr,lf,'* Error * Drive failed to respond.',cr,lf,cr,lf,stopper
msg40h DB cr,lf,cr,lf,'* Error * Seek operation failed.',cr,lf,cr,lf,stopper
msg20h DB cr,lf,cr,lf,'* Error * Controller failure.',cr,lf,cr,lf,stopper
msg10h DB cr,lf,cr,lf,'* Error * Bad CRC on diskette write.',cr,lf,cr,lf,stopper
msg08h DB cr,lf,cr,lf,'* Error * DMA overrun on operation.',cr,lf,cr,lf,stopper
msg04h DB cr,lf,cr,lf,'* Error * Requested sector not found.',cr,lf,cr,lf,stopper
msg03h DB cr,lf,cr,lf,'* Error * Write protected diskette.',cr,lf,cr,lf,stopper
msg02h DB cr,lf,cr,lf,'* Error * Address mark not found.',cr,lf,cr,lf,stopper
msggen DB cr,lf,cr,lf,'* Unknown Error *',cr,lf,cr,lf,stopper
;--------------------------------------------------------------------------
; Sub-Routines:
;--------------------------------------------------------------------------
Chk_Ver PROC NEAR
MOV AH,30h ;verify DOS 2.0 or later
INT 21h
CMP AL,2
JAE SHORT chk_ok
MOV DX,OFFSET sorry
JMP error
chk_ok:
RET
Chk_Ver ENDP
;--------------
Scan PROC NEAR ;check for any spurrious chars
MOV AL,[param2]
CMP AL,blank ;anything ?
JNZ shlp ;yes, give error msg
s1:
MOV AL,[param1] ;check for drive parameters
OR AL,AL ;anything ?
JZ shlp ;no -
CMP AL,01 ;setup for drive A:
JZ SHORT sdrvOk
CMP AL,02 ;for drive B:
JZ SHORT sdrvOk
shlp:
MOV DX,OFFSET usage ;display for invalid drives
JMP error
sdrvOk:
SUB AL,1 ;remember the drive.
sdrvDef:
MOV drive,AL
ADD AL,'A'
MOV drive_letter,AL
MOV DX,OFFSET logo
CALL Print
MOV DX,OFFSET msg1
RET
Scan ENDP
;--------------
Dwrite PROC NEAR ;transfer new disk boot sector
CALL Print ;get ready
d1: jmp d2
MOV AH,8 ;use function 8 in order to detect
INT 21h ;ctrl-breaks
CMP AL,ch_esc ;ESC & Ctrl-Break aborts process
JZ d5
CMP AL,cr
JNZ d1
d2:
MOV DX,OFFSET msg4 ;setup for disk write
CALL Print
MOV AL,drive ;read the old boot sector.
LEA BX,oldBoot
MOV CX,0001
MOV DX,0000
PUSH AX
PUSH BX
PUSH CX
PUSH DX
INT 25h
JC derror ;processing error ?
POPF ;done
POP DX
POP CX
POP BX
POP AX
MOV SI,OFFSET oldBoot+3+8 ;transfer the old bios parameters block.
MOV DI,OFFSET head+3+8 ;into the new sector.
MOV CX,OFFSET end_bpb
SUB CX,DI
REP MOVSB
MOV AL,drive
LEA BX,head
MOV CX,0001
MOV DX,0000
PUSH AX
PUSH BX
PUSH CX
PUSH DX
INT 26h
JC derror ;processing error ?
POPF ;done
POP DX
POP CX
POP BX
POP AX
d3:
MOV DX,OFFSET msg5 ;transfer complete
CALL Print
JMP d4
derror: ;display disk errror
CALL ErrorList
dend_of:
CALL Print
POPF ;done
POP DX
POP CX
POP BX
POP AX
d4:
jmp d5
MOV DX,OFFSET msg3 ;another ?
CALL Print
JMP d1 ;loop
d5:
RET
Dwrite ENDP
;--------------
Print PROC NEAR ;a Great idea from Vern Buerg !
PUSH SI
PUSH BX
PUSH CX
MOV SI,DX ;DX has the offset to string
SUB CX,CX ;set to zero for count
p1:
LODSB
CMP AL,stopper ;string ends in FFh
JE p9
INC CX ;increment text length
JMP p1
p9:
MOV AH,40h ;write using file handles
MOV BX,1
INT 21h
POP CX
POP BX ;recover registers
POP SI
RET
Print ENDP
;--------------
ErrorList PROC NEAR ;error code interpretation
;the upper byte (AH) contains error
err80h: CMP AH,080h ;attachment failed to respond
JNZ err40h
MOV DX,OFFSET msg80h
RET
err40h:
CMP AH,040h ;seek operation failed
JNZ err20h
MOV DX,OFFSET msg40h
RET
err20h:
CMP AH,020h ;controller failed
JNZ err10h
MOV DX,OFFSET msg20h
RET
err10h:
CMP AH,010h ;data error (bad CRC)
JNZ err08h
MOV DX,OFFSET msg10h
RET
err08h:
CMP AH,08h ;direct memory access failure
JNZ err04h
MOV DX,OFFSET msg08h
RET
err04h:
CMP AH,04h ;requested sector not found
JNZ err03h
MOV DX,OFFSET msg04h
RET
err03h:
CMP AH,03h ;write-protect fault
JNZ err02h
MOV DX,OFFSET msg03h
RET
err02h:
CMP AH,02h ;bad address mark
JNZ errgen
MOV DX,OFFSET msg02h
RET
errgen:
MOV DX,OFFSET msggen ;something new ? (Unknown)
RET
ErrorList ENDP
;--------------
;the new boot sector starts here.
head:
cr EQU 0Dh ;carriage return
lf EQU 0Ah ;line feed
stopper EQU 255 ;end of display line indicator
boot_area EQU 0000h ;setup boot area
hard_drv EQU 0080h ;setup hard drive
loc2 EQU 01FEh ;last two bytes of boot sector
eof_bootsec EQU 0AA55h ;end of boot sector (reversed)
bulc EQU 0DAh ;box upper left corner
burc EQU 0BFh ;box upper right corner
bllc EQU 0C0h ;box lower left corner
blrc EQU 0D9h ;box lower right corner
bver EQU 0B3h ;vertical
bhor EQU 0C4h ;horizontal
JMP startx ;1st byte of the sector must be a jmp
DB 'BootThru' ;8-byte system id
DW 512 ;sector size in bytes
DB 2 ;sectors per cluster
DW 1 ;reserved clusters
DB 2 ;number of fats
DW 112 ;root directory entries
DW 720 ;total sectors
DB 0FDh ;format id (2 sided, 9 sector)
DW 2 ;sectors per fat
DW 9 ;sectors per track
DW 2 ;sides
DW 0 ;special hidden sectors
here:
hdr_siz = 3+8+33h
lz = hdr_siz - (here - head)
db lz dup(0)
end_bpb: ;;;;; This is the end of the DOS5.0 BPB
startx: jmp start ; Must jump to here, to be identical
intro_beg:
DB cr,lf
DB cr,lf,bulc,46 DUP(bhor),burc
DB cr,lf,bver,' This disk was modified by BootThru Ver 1.08 ',bver
DB cr,lf,bver,'by Bill Gibson & Ray Van Tassle Booting C:',bver
DB cr,lf,bllc,46 DUP(bhor),blrc
DB cr,lf,stopper
intro_offset EQU intro_beg - head
start: MOV AX,07C0h ;boot record location
MOV ES,AX
MOV DS,AX
MOV SI,intro_offset
CLD ;just in case.
strt1: MOV AH,0Eh ;write teletype
LODSB
CMP AL,stopper
JE SHORT strt2
PUSH SI
INT 10h
POP SI
JMP SHORT strt1
strt2: CLD ;move the boot sector up.
MOV SI,0
MOV DI,0200h ;boot sector size
MOV CX,0200h
REPZ MOVSB
JMP strt3 + 200h ;jump to the new copy of it.
strt3: MOV AH,2 ;function 02h - read disk.
MOV BX,boot_area ;boot area
MOV CH,0 ;track number
MOV CL,1 ;sector
MOV DH,0 ;head
MOV DL,hard_drv ;hard drive
MOV AL,1 ;number of sectors
INT 13h
;setup to pull ROM Basic in if the hard drive has no boot sector.
strt4: CMP word ptr DS:loc2,eof_bootsec
JNZ strt9
JMP head - 200h ;jump to the new boot sector.
strt9: INT 18h
DB 'BootThru, Copyright (c) Bill Gibson'
tail:
filler_amount EQU 512 - (tail - head) - 2
DB filler_amount dup (0)
boot_id DW eof_bootsec
BootThru ENDP
oldBoot label byte
code ENDS
END BootThru